package com.springboot.erp.service.impl;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.erp.entity.JshSupplier;
import com.springboot.erp.mapper.JshSupplierMapper;
import com.springboot.erp.service.JshSupplierService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service

public class JshSupplierServiceImpl implements JshSupplierService {
    @Resource
    private JshSupplierMapper jshSupplierMapper;

    @Override
    public Page<JshSupplier> selectForPagesSupI(String supplier, String phoneNum, String telephone,
                                          int current,
                                          int size,
                                          String orderBy,
                                          boolean asc) {
        Page<JshSupplier> page = new Page<>(current, size);
        OrderItem orderItem = new OrderItem().setColumn(orderBy).setAsc(asc);
        page.addOrder(orderItem);
        page = jshSupplierMapper.selectForPagesSup(supplier, phoneNum, telephone, page);
        return page;
}

    @Override
    public void addOne(JshSupplier jshSupplier) {
        jshSupplierMapper.insrtONeSup(jshSupplier);
    }

    @Override
    public void updateOne(JshSupplier jshSupplier) {
        jshSupplierMapper.updateOneSup(jshSupplier);
    }

    @Override
    public void deleteOne(Integer id) {
        jshSupplierMapper.deleteOneSup(id);
    }

    @Override
    public Page<JshSupplier> selectForPagesSupIC(String supplier, String phoneNum, String telephone,
                                                 int current,
                                                 int size,
                                                 String orderBy,
                                                 boolean asc) {
        Page<JshSupplier> page = new Page<>(current, size);
        OrderItem orderItem = new OrderItem().setColumn(orderBy).setAsc(asc);
        page.addOrder(orderItem);
        page = jshSupplierMapper.selectForPagesSup(supplier, phoneNum, telephone, page);
        return page;
    }

    @Override
    public void addOneC(JshSupplier jshSupplier) {
        jshSupplierMapper.insrtONeSupC(jshSupplier);

    }

    @Override
    public void updateOneC(JshSupplier jshSupplier) {
        jshSupplierMapper.updateOneSupC(jshSupplier);

    }

    @Override
    public void deleteOneC(Integer id) {
        jshSupplierMapper.deleteOneSupC(id);

    }
}
